{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c62d2045",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8bc79ee7",
   "metadata": {},
   "outputs": [],
   "source": [
    "R = np.zeros((10,10))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7a27b509",
   "metadata": {},
   "outputs": [],
   "source": [
    "def ladder(f, n, a, b):\n",
    "    xArr = np.linspace(a, b, n + 1)\n",
    "    h = (b - a) / n\n",
    "    result = h * F(xArr) - h / 2 * (f(Xarr[0]) + f(xArr[-1]))\n",
    "    return result\n",
    "\n",
    "def F(xArr):\n",
    "    return np.sum(f(xArr))\n",
    "\n",
    "def f(x):\n",
    "    return x ** 2 - x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "30d1273e",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = -1\n",
    "b = 1\n",
    "for i in range(10):\n",
    "    R[i, 0] = ladderer(f, i+1, a, b)\n",
    "    for j in range(1, i):\n",
    "        R[i, j] = (4 ** j * R[i - 1, j - 1] - R[i, j - 1]) / (4 ** j - 1)\n",
    "        "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
